package MapReduce.Meta;

import java.io.*;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

public class WordCountMapper extends Mapper<Object, Text, Text, IntWritable> {
    private final static IntWritable one = new IntWritable(1);
    private final Text word = new Text();

    public void map(Object key, Text value, Context context) throws IOException, InterruptedException {

//        byte[] bt = value.getBytes();
//        InputStream ip = new ByteArrayInputStream(bt);
//        Reader read = new InputStreamReader(ip, StandardCharsets.UTF_8);
//        IKSegmenter iks = new IKSegmenter(read,true);
//        Lexeme t;
        String[] splits = value.toString().split(" ");
        for (String s : splits) {
            word.set(s);
            context.write(word, one);
        }
    }
}